import instance from "./header";

const request = class {
  constructor(url, arg) {
    this.url = url;
    this.arg = arg;
  }
  //post请求
  modePost() {
    return new Promise((resolve, reject) => {
      instance
        .post(this.url, this.arg)
        .then((res) => {
          //console.log(this.url, this.arg, resolve(res));
          resolve(res);
        })
        .catch((err) => {
          reject(err);
        });
    });
  }

  //get请求
  modeGet() {
    return new Promise((resolve, reject) => {
      instance
        .get(this.url)
        .then((res) => {
          resolve(res);
        })
        .catch((err) => {
          reject(err);
        });
    });
  }
};
export default request;
